<template>
    <h1>双向绑定指令</h1>
<!-- 双向绑定:将info 变量的值与页面上的元素进行绑定, 效果:
     1.info变量的值改变,页面上的文本框也会随之改变(Data Binding数据绑定)
     2.页面上的文本框输入内容,info变量的值也会随之改变(DOM Listeners 双向绑定)-->
  <input type="text" v-model="msg">
  <button @click="console.log(msg)">按钮</button>
    <h3>用户登录</h3>
  <input type="text" placeholder="输入用户名" v-model="user.name">
  <input type="password" placeholder="输入密码" v-model="user.password">
  <br>
  <input type="radio" name="gender" value="1" v-model="user.gender">男
  <input type="radio" name="gender" value="0" v-model="user.gender">女
  <button @click="login()">登录</button>

</template>
<script setup>
import {ref} from "vue";
const msg = ref('双向绑定');
const user = ref({name:'孙雪宁', password:'12456', gender:'0'});
const login = () => {
  console.log(user.value);
  console.log(user.value.name);
  console.log(user.value.password);
  console.log(user.value.gender);
}

</script>
<style scoped>

</style>